<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Forum extends Model
{
    use HasFactory;

    // 一对一
    public function category()
    {
        return $this->hasOne(ForumCategory::class, 'id','category_id');
    }

    // 一对一
    public function user()
    {
        return $this->hasOne(User::class, 'id', 'user_id');
    }

    // 多态关联
    public function comments()
    {
        return $this->morphMany(Comment::class, 'commentable');
    }
}
